<template>
	<view class="container2">
		<cover-view class="laytab">
			<cover-view class="tab" :class="TabIndex==1?'select':''" @click="LayTab(1)">电子文书</cover-view>
			<cover-view class="tab left20" :class="TabIndex==2?'select':''" @click="LayTab(2)">图片文书</cover-view>
		</cover-view>
		<view class="webview" v-if="TabIndex==1">
			<!-- #ifdef APP-->
			<web-view :update-title="false" :src="Domain+'/Admin/Case/'+Method+'.aspx?From=App&ID='+CaseID+'&Token='+Token+'&SubName='+SubName"></web-view>
			<!-- #endif -->
			<!-- #ifdef MP-WEIXIN || H5 -->
			<view class="preview" @click="Tools.Preview_County(CaseID,Method,SubName)">点此预览文书</view>
			<!-- #endif -->
		</view>
		<template v-else>
			<view class="square1 imglist5" v-if="(OldList.length+ImgList.length)>0">
				<view class="line1">
					<view class="img border" v-for="(img,index) in OldList"><image :src="Tools.GetImg(img,500)" mode="aspectFill" @click="Tools.PrevImg(OldList,index)"/><view class="delete" @click="DeleteImg1(index)" @click.stop="" v-if="Item.State==1"><image src="/static/error.png"/></view></view>
					<view class="img border" v-for="(img,index) in ImgList"><image :src="img" mode="aspectFill" @click="Tools.PrevImg(ImgList,index)"/><view class="delete" @click="DeleteImg2(index)" @click.stop="" v-if="Item.State==1"><image src="/static/error.png"/></view></view>
				</view>
			</view>
			<view class="imglist5" v-else>
				<view class="nodata"></view>
				<view class="loadmore">暂无图片</view>
			</view>
		</template>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				CaseID:0,
				AnnexID:0,
				RoleID:0,
				Item:{ID:0},
				SubName:'',
				Method:'',
				Expand:{},
				Token:'',
				Domain:'',
				TabIndex:1,
				OldList:[],
				ImgList:[]
			};
		},
		onReady() {
			// #ifdef APP-PLUS
			this.Util.Loading("加载中,请稍候...");
			var currentWebview = this.$scope.$getAppWebview(); //获取当前页面的webview对象
			setTimeout(()=> {
				var wv = currentWebview.children()[0] //取出当前webview实例
				wv.setStyle({
					scalable: true  //添加样式，启动缩放
				});
				wv.addEventListener('loaded', ()=> {
					///this.Util.HideLoading();
				}, false);
			}, 1000); //如果是页面初始化调用时，需要延时一下
			setTimeout(()=> {
				this.Util.HideLoading();
			},1000);
			// #endif
		},
		onLoad(options) {
			uni.setNavigationBarTitle({title:options.SubName});
			this.SubName=options.SubName;
			this.Method=options.Method;
			this.CaseID=options.CaseID;
			this.Domain = uni.getStorageSync("Domain");
			this.RoleID=uni.getStorageSync("RoleID");
			this.Token=uni.getStorageSync("Token") || '';
			this.Find_CaseInfo();
		},
		methods:{
			LayTab(TabIndex){
				this.TabIndex=TabIndex;
				// #ifdef APP-PLUS
				if(this.TabIndex==1){
					this.Util.Loading("加载中,请稍候...");
					var currentWebview = this.$scope.$getAppWebview(); //获取当前页面的webview对象
					setTimeout(()=> {
						var wv = currentWebview.children()[0] //取出当前webview实例
						wv.setStyle({
							scalable: true  //添加样式，启动缩放
						});
					}, 1000);
					setTimeout(()=> {
						this.Util.HideLoading();
					},1000);
				}
				// #endif
			},
			Find_CaseInfo(){
				var data = {};
				data.Act="Find_CaseInfo_County";
				data.CaseID=this.CaseID;
				data.Method=this.Method;
				data.Domain=this.Domain;
				this.Util.Loading("加载中...");
				this.Util.Post(data, json=>{
					this.Util.HideLoading();
					uni.stopPullDownRefresh();
					uni.hideNavigationBarLoading();
					this.Item = json.Data.Info;
					this.Expand=json.Data.Expand;
					this.OldList = json.Data.ImgList;
					this.AnnexID = json.Data.AnnexID;
				});
			}
		}
	}
</script>

<style lang="scss">
	page{background-color: #f7f7f7;}
</style>
